<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <el-page-header style="background-color: dimgrey;
        color: white; line-height: 60px" @back="goBack" content="修改课程信息">
    </el-page-header>
    <el-card style="width: 600px; height: 800px; margin: 0 auto">
        <el-form label-width="80px">
            <el-form-item label="课程名称">
                <el-input type="text" v-model="c.name"></el-input>
            </el-form-item>
            <el-form-item label="所属系">
                <el-input type="text" v-model="c.dept"></el-input>
            </el-form-item>
            <el-form-item label="年级">
                <el-select v-model="c.year">
                    <el-option label="大一" value="大一"></el-option>
                    <el-option label="大二" value="大二"></el-option>
                    <el-option label="大三" value="大三"></el-option>
                    <el-option label="大四" value="大四"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="教师">
                <el-input type="text" v-model="c.teacher"></el-input>
            </el-form-item>
            <el-form-item label="上课时间">
                <el-select v-model="c.times">
                    <el-option label="周一第一节" value="周一第一节"></el-option>
                    <el-option label="周一第二节" value="周一第二节"></el-option>
                    <el-option label="周一第三节" value="周一第三节"></el-option>
                    <el-option label="周一第四节" value="周一第四节"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="上课地点">
                <el-input v-model="c.loc"></el-input>
            </el-form-item>
            <el-form-item label="学分">
                <el-input v-model="c.credit"></el-input>
            </el-form-item>
            <el-form-item label="课程类型">
                <el-select v-model="c.type">
                    <el-option label="必修" value="必修"></el-option>
                    <el-option label="选修" value="选修"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="success" @click="courseUpdate()">修改</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>

<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                c:{}
            }
        },
        methods: {
            courseUpdate(){
                //发出修改商品的请求
                axios.post("/course/update",v.c).then(function (response) {
                    location.href = "/admin.html";
                })
            },
            goBack() {
                history.back();//返回上一页面
            },
        },
        created: function () {
            //通过id请求需要修改的商品信息
            axios.get("/course/selectById/update"+location.search).then(function (response) {
                v.c = response.data;
            })
        }
    })
</script>
</html>